var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/Attachment/components/CategoryTree.tsx
var CategoryTree_exports = {};
__export(CategoryTree_exports, {
  CategoryTree: () => CategoryTree
});
module.exports = __toCommonJS(CategoryTree_exports);
var import_icons = require("@ant-design/icons");
var import_react = require("react");
var import_baseComponent = require("../../../baseComponent");
var import_util = require("../../../util");
var CategoryTree = (props) => {
  const { data = [], onSelect, style } = props;
  const [selectedKey, setSelectedKey] = (0, import_react.useState)("");
  const [searchName, setSearchName] = (0, import_react.useState)("");
  const [inputValue, setInputValue] = (0, import_react.useState)("");
  const dataList = (0, import_react.useMemo)(
    () => data.map((item) => ({
      ...item,
      title: item.typeName,
      key: item.typeId,
      icon: /* @__PURE__ */ React.createElement(import_icons.FolderFilled, null)
    })),
    [data]
  );
  const filterDataList = (0, import_react.useMemo)(
    () => dataList.filter((item) => item.title.includes(searchName)),
    [dataList, searchName]
  );
  (0, import_react.useEffect)(() => {
    var _a;
    ((_a = dataList == null ? void 0 : dataList[0]) == null ? void 0 : _a.key) != null && setSelectedKey(dataList[0].key);
  }, []);
  return /* @__PURE__ */ React.createElement(import_util.Layout, { direction: "column", className: "attachment-category", style }, /* @__PURE__ */ React.createElement("div", { className: "attachment-category-search-container" }, /* @__PURE__ */ React.createElement(
    import_baseComponent.Input,
    {
      className: "attachment-category-search",
      bordered: false,
      value: inputValue,
      onChange: setInputValue,
      suffix: /* @__PURE__ */ React.createElement(import_icons.SearchOutlined, { style: { color: "rgba(0,0,0,.45)" }, onClick: () => setSearchName(inputValue) })
    }
  )), /* @__PURE__ */ React.createElement("div", { className: "attachment-category-title" }, "分类名称"), /* @__PURE__ */ React.createElement(import_util.Layout.Flex, { className: "attachment-category-content" }, filterDataList.map((item) => /* @__PURE__ */ React.createElement(
    "div",
    {
      className: `attachment-category-item ${item.key === selectedKey ? "attachment-category-item-selected" : ""}`,
      key: item.key,
      onClick: () => {
        setSelectedKey(item.key);
        onSelect(item.key);
      }
    },
    +item.mustInput === 1 ? /* @__PURE__ */ React.createElement("span", { style: { color: "red" } }, "*") : null,
    /* @__PURE__ */ React.createElement("span", null, item.title),
    /* @__PURE__ */ React.createElement("span", { className: "attachment-category-item-count" }, "（", item.count, "）")
  ))));
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CategoryTree
});
